package visao.Matricula;

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import visao.aluno.BuscadeAlunos;

import modelagem.Aluno;

import com.towel.swing.table.ObjectTableModel;

import controle.Matricula.AcaoDaTelaBusca;

@SuppressWarnings("serial")
public class TelaBuscaAlunosMatriculados extends JDialog {

	private final JPanel contentPanel = new JPanel();
	private JTextField txtNome;
	private JButton btnOk, btnCancelar;
	private JButton bntCancelar;
	private AcaoDaTelaBusca acaoTBusca;
	private JTable table;
	private ObjectTableModel<Aluno> modeloTabela = new BuscadeAlunos(null).getModeloTabela();
	private JButton btnSelecionar;
	private TelaMatricula tm;
	
	
	public TelaBuscaAlunosMatriculados(TelaMatricula tm) {
		this.tm = tm;
		setBounds(100, 100, 450, 300);
		setLocationRelativeTo(null);
		setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		
		
		acaoTBusca = new AcaoDaTelaBusca(this);
		table = new JTable(modeloTabela);
		table.getColumnModel().getColumn(0).setPreferredWidth(10);
		table.getColumnModel().getColumn(1).setPreferredWidth(300);
		
		JScrollPane scrollPane = new JScrollPane(table);
		scrollPane.setBounds(10, 25, 414, 163);
		contentPanel.add(scrollPane);
		
		JLabel lblNome_1 = new JLabel("Nome");
		lblNome_1.setBounds(10, 203, 46, 14);
		contentPanel.add(lblNome_1);
		
		txtNome = new JTextField();
		txtNome.setBounds(55, 200, 369, 20);
		contentPanel.add(txtNome);
		txtNome.setColumns(10);
		{
			JPanel buttonPane = new JPanel();
			buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
			getContentPane().add(buttonPane, BorderLayout.SOUTH);
			{
				btnOk = new JButton("Buscar");
				btnOk.setActionCommand("OK");
				btnOk.addActionListener(acaoTBusca);
				buttonPane.add(btnOk);
				getRootPane().setDefaultButton(btnOk);
			}
			{
				btnCancelar = new JButton("Cancel");
				btnCancelar.addActionListener(acaoTBusca);
				
				btnSelecionar = new JButton("Selecionar");
				btnSelecionar.addActionListener(acaoTBusca);
				buttonPane.add(btnSelecionar);
				btnCancelar.setActionCommand("Cancel");
				buttonPane.add(btnCancelar);
			}
		}
	}

	public JPanel getContentPanel() {
		return contentPanel;
	}

	public JTextField getTxtNome() {
		return txtNome;
	}

	public JButton getBtnOk() {
		return btnOk;
	}

	public JButton getBntCancelar() {
		return bntCancelar;
	}
	public JButton getBtnCancelar() {
		return btnCancelar;
	}
	public JTable getTable() {
		return table;
	}

	public ObjectTableModel<Aluno> getModeloTabela() {
		return modeloTabela;
	}
	public JButton getBtnSelecionar() {
		return btnSelecionar;
	}

	public TelaMatricula getTm() {
		return tm;
	}
}
